package com.boe.hbd.server.processor;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.fastjson.JSON;
import com.boe.hbd.server.dao.UserDao;
import com.boe.hbd.server.model.User;

public class UserProcessor extends BaseProcessor {

	UserDao userDao = UserDao.getInstance();
	
	private static UserProcessor instance = new UserProcessor();
	private UserProcessor(){}
	public static UserProcessor getInstance(){
		return instance;
	}

	@Override
	String deal(String[] args, HttpServletRequest req) {
		String method = args[2];
		if (ADD.equals(method)) {
			User user = new User();
			user.setSnsID(args[3]);
			userDao.add(user);
			return SUCCESS;
		}
		if (QUERY.equals(method)) {
			User user = userDao.findUser(args[3]);
			return JSON.toJSONString(user);
		}
		return FAILED;
	}

}
